//
//  NavigationController.swift
//  MYModule
//
//  Created by 李然 on 2022/7/19.
//

import UIKit
import EachNavigationBar

open class NavigationController: UINavigationController {
    
  
    open override func viewDidLoad() {
        super.viewDidLoad()
        // present 全屏
        self.modalPresentationStyle = .fullScreen
        
        view.backgroundColor = UIColor.white
        navigation.configuration.isEnabled = true
        navigation.configuration.isTranslucent = false
        navigation.configuration.barTintColor = UIColor.white
        navigation.configuration.isShadowHidden = true
        navigation.configuration.tintColor = UIColor.black
        
        navigation.configuration.backItem = UINavigationController.Configuration.BackItem.init(style: .image(UIImage(named: "ic_back")?.originalImageWithColor(color: UIColor.black)))
        navigation.configuration.titleTextAttributes = [.foregroundColor: UIColor.black, .font: Fonts.systemFont(ofSize: 20)]

    }
    
    open override func pushViewController(_ viewController: UIViewController, animated: Bool) {
        if viewControllers.count >= 1 {
            viewController.hidesBottomBarWhenPushed = true
        }
        super.pushViewController(viewController, animated: animated)
    }
    
    
    open override var preferredStatusBarStyle: UIStatusBarStyle {
     
        return self.topViewController!.preferredStatusBarStyle
    }
    
    open override var shouldAutorotate: Bool {
        
        return topViewController?.shouldAutorotate ?? false
    }
    
    open override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        
        return topViewController?.supportedInterfaceOrientations ?? .portrait
    }
    
    open override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
        
        return topViewController?.preferredInterfaceOrientationForPresentation ?? .portrait
        
    }
    
    
    
}
